#include <iostream>
#include <memory>
#include "tcp_server.hpp"
#include "daemon.hpp"
#include "err.hpp"
using namespace std;
using namespace tcp_server;

void Usage(string u)
{
    cout << "Usage:\n\t" << u << " port" << endl;
}
string To(string message)
{
    return message;
}
int main(int argv,char* argc[])
{
    if(argv != 2)
    {
        Usage(argc[0]);
        exit(USAGE_ERROR);
    }
    uint16_t port = atoi(argc[1]);
    cout<<port<<endl;
    unique_ptr<TcpServer> utsv(new TcpServer(To,port));
    //初始化
    utsv->Initserver();
    //创建守护进程
    daemon();
    //启动
    utsv->Start();
    return 0;
}